extends Area2D

enum State {WALK,ATTACK}
var selected_type = "normal"
var state = State.WALK
var blood = 100
var row = 0
var level

func _ready():
	$Animate.play(selected_type)
	
func _process(delta: float) -> void:
	if state == State.WALK:
		position.x -= 30 * delta
		
func _on_area_entered(area: Area2D) -> void:
	if area.is_in_group("bullet"):
		blood -= 20
		if blood <= 0:
			queue_free()
			level.zombie_die(row)
	else:
		state = State.ATTACK
		$Animate.play(selected_type + "Attack")


func _on_area_exited(area: Area2D) -> void:
	if not area.is_in_group("bullet"):
		state = State.WALK
		$Animate.play(selected_type)
